﻿using System.Drawing;
using System.Windows;
using System.Windows.Controls;

namespace Tests.UI
{
    /// <summary>
    /// Interaction logic for ToolbarControl.xaml
    /// </summary>
    public partial class MultilineToolbarTray
    {
        public MultilineToolbarTray()
        {
            InitializeComponent();
            Rows = new[]
            {
                new ToolbarRow
                {
                    Items = new[]
                    {
                       new ToolbarItem{Title = "link 1",
                       FilePath = @"D:\My Documents\Visual Studio 2008\Projects\Toolbar\Toolbar\ApplicationDesktopToolbar.cs" },
                       new ToolbarItem{Title =  "link 2",
                       FilePath = @"D:\My Documents\Visual Studio 2008\Projects\Toolbar\Toolbar\"},
                    }
                }, 
                new ToolbarRow
                {
                    Items = new[]
                    {
                       new ToolbarItem{Title =  "link 3",
                       FilePath = @"D:\My Documents\Visual Studio 2008\Projects\Toolbar\Tests\Icon1.ico"},
                       new ToolbarItem{Title =  "link 4",
                       FilePath = @"D:\My Documents\Visual Studio 2008\Projects\Toolbar\Toolbar\Properties\Resources.resx"},
                    }
                },
                new ToolbarRow
                {
                    Items = new[]
                    {
                       new ToolbarItem{Title =  "link 5",
                       FilePath = @"D:\My Documents\Visual Studio 2008\Projects\Toolbar\Toolbar\Properties\Settings.settings"},
                        new ToolbarItem{Title = "link 6",
                       FilePath = @"D:\My Documents\Visual Studio 2008\Projects\Toolbar\Toolbar\ROOT.WMI.WinLogon.cs"},
                    }
                },new ToolbarRow
                {
                    Items = new[]
                    {
                        new ToolbarItem{Title = "link 5",
                       FilePath = @"D:\My Documents\Visual Studio 2008\Projects\Toolbar\Toolbar\ApplicationDesktopToolbar.cs"},
                        new ToolbarItem{Title = "link 6",
                       FilePath = @"D:\My Documents\Visual Studio 2008\Projects\Toolbar\Toolbar\UsbDriveNotificator.cs"},
                    }
                },new ToolbarRow
                {
                    Items = new[]
                    {
                        new ToolbarItem{Title = "link 5",
                       FilePath =@"D:\My Documents\Visual Studio 2008\Projects\Toolbar\Toolbar\ShellApi.cs"},
                        new ToolbarItem{Title = "link 6",
                       FilePath = @"D:\My Documents\"},
                    }
                },new ToolbarRow
                {
                    Items = new[]
                    {
                       new ToolbarItem{Title =  "link 5",
                       FilePath = @""},
                        new ToolbarItem{Title = "link 6",
                       FilePath = @""},
                    }
                },
            };
        }



        public ToolbarRow[] Rows
        {
            get { return (ToolbarRow[])GetValue(LinksProperty); }
            set { SetValue(LinksProperty, value); }
        }

        // Using a DependencyProperty as the backing store for Links.  This enables animation, styling, binding, etc...
        public static readonly DependencyProperty LinksProperty =
            DependencyProperty.Register("Rows", typeof(ToolbarRow[]), typeof(MultilineToolbarTray), new UIPropertyMetadata(new ToolbarRow[0]));


        public Orientation Orientation
        {
            get { return Tray.Orientation; }
            set
            {
                Tray.Orientation = value;
                Content = null;
                Content = Tray;
            }
        }


        private void Button_Click(object sender, RoutedEventArgs e)
        {
            var toolbarItem = ((ToolbarItem)((Button)sender).CommandParameter);
            if (toolbarItem != null && toolbarItem.Click != null)
            {
                toolbarItem.Click();
            }
        }
    }
}
